(* Creme Caramel Compiler (Triple C) - Michele Caceffo - 2008 *)

open Exceptions;;

(* identifiers *)
type ide = Ide of string

(* arithmetical expressions *)
type aexp  =
	  N of int
    | R of float  
	| Var of ide
    | Vec of ide * aexp   
    | Mat of ide * aexp * aexp
	| Sum of aexp * aexp
    | Sub of aexp * aexp
	| Mul of aexp * aexp
	| Div of aexp * aexp
    | FCall of ide * aexp list
    | VecSearch of ide * aexp
    

(* boolean expressions *)
and bexp =
	  B of bool
	| Equ of aexp * aexp
        | NotEqu of aexp * aexp
	| LE of aexp * aexp
	| LT of aexp * aexp
	| Not of bexp
	| And of bexp * bexp
	| Or of bexp * bexp

(* left expressions *)
type lexp =
      LVar of ide
    | LMat of ide * aexp * aexp
    | LVecModify of ide * aexp
    | LVecAdd of ide * aexp

(* commands *)
type cmd =
	  Ass of lexp * aexp
	| Blk of cmd list
	| Ite of bexp * cmd * cmd
	| While of bexp * cmd
	| Write of aexp
    | PCall of ide * aexp list
    | VecDelete of ide * aexp
    

(* declarations *)
type bType = Int
           | Float

type gType =
      Basic of bType
    | Vector of  int * bType
    | Matrix of int * int * bType

type dec = Dec of ide * gType

(* procedures / functions *)
type param = Par of ide * bType

type ret = Ret of bType

type proc = Proc of ide * param list * dec list * cmd
          | Func of ide * param list * ret * dec list * cmd

(* programs *)
type program = Program of dec list * proc list * cmd | SynError
